﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       Shpm.App.Input.Dao.PhyscalDao
 * 类型：       DAO
 * 功能说明：   体检报告
 * 作者：       谈震鸣
 * 创建日期：   2007/08/24
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using Shpm.App.Input.Bean;
using Shpm.System.Db;
using Shpm.App.Commons.Utils;


namespace Shpm.App.Input.Dao
{
    public class PhyscalDao : ShpmBaseDao
    {
        public const string FIND_BY_PHYSCAL = "Physcal.FindByPhyscal";
        public const string FIND_BY_PHYSCAL_INFO = "Physcal.FindByPhyscalInfo";
        public const string FIND_BY_POSONALPHYSCAL = "Physcal.FindByPosonalPhyscal";
        public const string INSERT_PHYSCAL = "Physcal.InsertPhyscal";
        public const string UPDATE_PHYSCAL = "Physcal.UpdatePhyscal";
        public const string DELETE_PHYSCAL = "Physcal.DeletePhyscal";
        public const string FIND_BY_PERSON = "Physcal.FindByPerson";
        public const string FIND_BY_PERSONINFO = "Physcal.FindByPersonInfo";
        public const string FIND_BY_SALESPROC = "Physcal.FindBySalesProc";
        public PhyscalDao()
        {
        }
        //检索体检表
        public IList FindByPhyscal(PhyscalBean paramBean)
        {
            return base.QueryForList(FIND_BY_PHYSCAL, paramBean);
        }
        //检索体检表
        public IList FindByPhyscalInfo(PhyscalBean paramBean)
        {
            return base.QueryForList(FIND_BY_PHYSCAL_INFO, paramBean);
        }
        //检索体检表
        public IList FindByPhyscal(string PersonId, string Name, string SendDate,string SendDateTo)
        {
            try
            {
                PhyscalBean dataBean = new PhyscalBean();
                if (PersonId != "-1") dataBean.PersonId = int.Parse(PersonId);
                if (Name != "-1") dataBean.Name = Name;
                if (SendDate != "-1") dataBean.SendDate = DateUtils.convertToDate(SendDate);
                if (SendDateTo != "-1") dataBean.SendDateTo = DateUtils.convertToDate(SendDateTo);
                return this.FindByPhyscal(dataBean);
            }
            catch (DataAccessException e)
            {
                Console.WriteLine("********** Exec  sql error! **********");
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                throw (e);
                return null;
            }
        }
        //读取某张体检表
        public PhyscalBean Load(PhyscalBean paramBean)
        {
            return (PhyscalBean)base.QueryForObject(FIND_BY_POSONALPHYSCAL, paramBean);
        }
        //插入数据
        public Object InsertPhyscal(PhyscalBean paramBean)
        {
            return base.Insert(INSERT_PHYSCAL, paramBean);
        }
        //更新数据
        public int UpdatePhyscal(PhyscalBean paramBean)
        {
            return base.Update(UPDATE_PHYSCAL, paramBean);
        }
        //删除数据
        public int DeletePhyscal(PhyscalBean paramBean)
        {
            return base.Delete(DELETE_PHYSCAL, paramBean);
        }


        //检索人员表
        public IList FindByPerson(PhyscalBean paramBean)
        {
            return base.QueryForList(FIND_BY_PERSON, paramBean);
        }
        //检索人员表
        public IList FindByPerson( string PersonId, string Name, string Sex)
        {
            try
            {
                PhyscalBean dataBean = new PhyscalBean();
                if (PersonId != "-1") dataBean.PersonId = int.Parse(PersonId);
                if (Name != "-1") dataBean.Name = Name;
                if (Sex != "00") dataBean.Sex = Sex;
                return this.FindByPerson(dataBean);
            }
            catch (DataAccessException e)
            {
                Console.WriteLine("********** Exec  sql error! **********");
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                throw (e);
                return null;
            }
        }
        //人员信息
        public PhyscalBean PersonLoad(PhyscalBean paramBean)
        {
            return (PhyscalBean)base.QueryForObject(FIND_BY_PERSONINFO, paramBean);
        }

        //检查是否被占用
        public IList FindBySalesProc(PhyscalBean paramBean)
        {
            return base.QueryForList(FIND_BY_SALESPROC, paramBean);
        }
    }
}